
import Foundation
import Alamofire
import SwiftyJSON
import SFFundation

public enum TemplateRouter: BaseRouterUrlProtocol {
    
    static let baseURLString = CommonUtils.baseURL
    
    case Activity_FindByID
    
    public var method: Alamofire.HTTPMethod {
        switch self {
            
        case .Activity_FindByID:
            return .get
        }
    }
    
    public var showMessage: Bool{
        return true
    }
    
    public var path: String {
        switch self {
            
        case .Activity_FindByID:
            return "api/v3/huodong/"
        }
    }
    
    public func asURLRequest() throws -> URLRequest {
        let url = URL(string: TemplateRouter.baseURLString)!
        var urlRequest = URLRequest(url: url.appendingPathComponent(path))
        urlRequest.httpMethod = method.rawValue
        var parameters:Parameters? = nil
        var headers:HTTPHeaders? = nil
        
        if headers != nil {
            for (headerField, headerValue) in headers! {
                urlRequest.setValue(headerValue, forHTTPHeaderField: headerField)
            }
        }
        if parameters != nil {
            return try! Alamofire.URLEncoding.default.encode(urlRequest, with: parameters!)
        }
        
        return urlRequest
    }
}
